﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ORMAC.Attributes;
namespace ORMAC.CodeGen.DBObjects
{
    [SQL(Query=@"SELECT K.TABLE_NAME,
            K.COLUMN_NAME,
            K.CONSTRAINT_NAME
            FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS C
            JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS K
            ON C.TABLE_NAME = K.TABLE_NAME
            AND C.CONSTRAINT_CATALOG = K.CONSTRAINT_CATALOG
            AND C.CONSTRAINT_SCHEMA = K.CONSTRAINT_SCHEMA
            AND C.CONSTRAINT_NAME = K.CONSTRAINT_NAME
            WHERE C.CONSTRAINT_TYPE = 'PRIMARY KEY'")]
    public class PrimaryKeyInfo
    {
        [PrimaryKey]
        [Field("COLUMN_NAME")]
        public string KeyName { get; set; }
        [PrimaryKey]
        [Field("TABLE_NAME")]
        public string TableName { get; set; }
    }
}
